this.BX=this.BX||{};this.BX.Landing=this.BX.Landing||{};(function(e,i){"use strict";var s=function(){function e(i){babelHelpers.classCallCheck(this,e);this.idDomainName=i.idDomainName;this.idDomainMessage=i.idDomainMessage;this.idDomainLoader=i.idDomainLoader;this.idDomainLength=i.idDomainLength||null;this.idDomainErrorAlert=i.idDomainErrorAlert;this.classes={dangerBorder:"ui-ctl-danger",successBorder:"ui-ctl-success",dangerAlert:"landing-domain-alert-danger",successAlert:"landing-domain-alert-success"};if(this.idDomainName){this.idDomainNameParent=this.idDomainName.parentNode}}babelHelpers.createClass(e,[{key:"showLoader",value:function e(){this.clearMessage();this.hideLength();i.Dom.show(this.idDomainLoader)}},{key:"hideLoader",value:function e(){this.showLength();i.Dom.hide(this.idDomainLoader)}},{key:"isLoaderShowed",value:function e(){return this.idDomainLoader&&this.idDomainLoader.style.display!=="none"}},{key:"setLength",value:function s(t){var a=arguments.length>1&&arguments[1]!==undefined?arguments[1]:e.DEFAULT_LENGTH_LIMIT;if(this.idDomainLength){this.idDomainLength.innerHTML=i.Loc.getMessage("LANDING_TPL_DOMAIN_LENGTH_LIMIT",{"#LENGTH#":t,"#LIMIT#":a})}i.Dom.show(this.idDomainLength)}},{key:"hideLength",value:function e(){if(this.idDomainLength){i.Dom.hide(this.idDomainLength)}}},{key:"showLength",value:function e(){if(this.idDomainLength){i.Dom.show(this.idDomainLength)}}},{key:"setSuccess",value:function e(s){if(this.idDomainErrorAlert){i.Dom.hide(this.idDomainErrorAlert)}this.setMessage(s)}},{key:"setError",value:function e(i){this.setMessage(i,true)}},{key:"isErrorShowed",value:function e(){return this.idDomainMessage&&i.Dom.hasClass(this.idDomainMessage,this.classes.dangerAlert)&&this.idDomainMessage.style.display!=="none"}},{key:"setMessage",value:function e(s,t){if(!this.idDomainMessage){return}t=!!t;this.clearMessage();if(s){if(this.idDomainNameParent){i.Dom.addClass(this.idDomainNameParent,t?this.classes.dangerBorder:this.classes.successBorder)}i.Dom.addClass(this.idDomainMessage,t?this.classes.dangerAlert:this.classes.successAlert);i.Dom.show(this.idDomainMessage);this.idDomainMessage.innerHTML=s}}},{key:"clearMessage",value:function e(){if(!this.idDomainMessage){return}if(this.idDomainNameParent){i.Dom.removeClass(this.idDomainNameParent,this.classes.dangerBorder);i.Dom.removeClass(this.idDomainNameParent,this.classes.successBorder)}i.Dom.removeClass(this.idDomainMessage,this.classes.dangerAlert);i.Dom.removeClass(this.idDomainMessage,this.classes.successAlert);this.idDomainMessage.innerHTML=""}}]);return e}();babelHelpers.defineProperty(s,"DEFAULT_LENGTH_LIMIT",63);var t=function(){function e(t){var a=this;babelHelpers.classCallCheck(this,e);this.domainId=t.domainId;this.domainName=t.domainName;this.domainPostfix=t.domainPostfix||"";this.idDomainName=t.idDomainName;this.idDomainINA=t.idDomainINA;this.idDomainDnsInfo=t.idDomainDnsInfo;this.idDomainSubmit=t.idDomainSubmit;this.previousDomainName=null;this.helper=new s(t);this.tld=t.tld?t.tld.toLowerCase():"tld";this.classes={submit:"ui-btn-clock"};this.keyupCallback=this.keyupCallback.bind(this);if(this.idDomainName){i.Event.bind(this.idDomainName,"keyup",i.Runtime.debounce(this.keyupCallback,900));var n=i.Type.isString(this.idDomainName.value)?this.idDomainName.value.trim():"";if(n.length===0){this.helper.setLength(0)}else{this.keyupCallback()}}if(this.idDomainSubmit){i.Event.bind(this.idDomainSubmit,"click",(function(e){a.checkSubmit(e)}))}this.fillDnsInstruction(this.domainName)}babelHelpers.createClass(e,[{key:"domainNameIsEmpty",value:function e(){this.idDomainName.value=i.Type.isString(this.idDomainName.value)?this.idDomainName.value.trim():this.idDomainName.value;return this.idDomainName.value===""}},{key:"checkSubmit",value:function e(s){if(i.Dom.hasClass(this.idDomainSubmit,this.classes.submit)){s.preventDefault()}else if(this.domainNameIsEmpty()){this.helper.setError(i.Loc.getMessage("LANDING_TPL_ERROR_DOMAIN_EMPTY"));s.preventDefault()}else if(this.helper.isErrorShowed()){s.preventDefault()}else{i.Dom.addClass(this.idDomainSubmit,this.classes.submit)}}},{key:"keyupCallback",value:function e(){this.idDomainName.value=i.Type.isString(this.idDomainName.value)?this.idDomainName.value.trim():this.idDomainName.value;if(this.idDomainName.value===""){this.helper.setError(i.Loc.getMessage("LANDING_TPL_ERROR_DOMAIN_EMPTY"));this.helper.setLength(0);return}var s=this.idDomainName.value;if(this.previousDomainName===s){return}this.previousDomainName=s;this.helper.showLoader();BX.ajax({url:"/bitrix/tools/landing/ajax.php?action=Domain::check",method:"POST",data:{data:{domain:s+this.domainPostfix,filter:this.domainId?{"!ID":this.domainId}:{}},sessid:i.Loc.getMessage("bitrix_sessid")},dataType:"json",onsuccess:function(e){this.helper.hideLoader();if(e.type==="success"){if(e.result.length&&e.result.length.length&&e.result.length.limit){this.helper.setLength(e.result.length.length,e.result.length.limit)}else{this.helper.hideLength()}if(!e.result.available){if(e.result.errors){if(e.result.errors.wrongSymbols){this.helper.setError(i.Loc.getMessage("LANDING_TPL_ERROR_DOMAIN_WRONG_NAME"))}else if(e.result.errors.wrongLength){this.helper.setError(i.Loc.getMessage("LANDING_TPL_ERROR_DOMAIN_WRONG_LENGTH"))}else if(e.result.errors.wrongSymbolCombination){this.helper.setError(i.Loc.getMessage("LANDING_TPL_ERROR_DOMAIN_WRONG_SYMBOL_COMBINATIONS"))}else if(e.result.errors.wrongDomainLevel){this.helper.setError(i.Loc.getMessage("LANDING_TPL_ERROR_DOMAIN_WRONG_DOMAIN_LEVEL"))}}else{this.helper.setError(!!e.result.deleted?i.Loc.getMessage("LANDING_TPL_ERROR_DOMAIN_EXIST_DELETED"):i.Loc.getMessage("LANDING_TPL_ERROR_DOMAIN_EXIST"))}}else if(!e.result.domain){this.helper.setError(i.Loc.getMessage("LANDING_TPL_ERROR_DOMAIN_INCORRECT"))}else{this.fillDnsInstruction(e.result.domain);this.helper.setSuccess(i.Loc.getMessage("LANDING_TPL_DOMAIN_AVAILABLE"))}if(e.result.dns&&this.idDomainINA){this.idDomainINA.textContent=e.result.dns["INA"]}}else{this.helper.setError("Error processing")}}.bind(this)})}},{key:"fillDnsInstruction",value:function e(i){if(!this.idDomainDnsInfo){return}if(!i){return}if(!this.idDomainDnsInfo.rows[1]){return}if(!this.idDomainDnsInfo.rows[2]){return}if(this.idDomainDnsInfo.rows[1].cells.length<3||this.idDomainDnsInfo.rows[2].cells.length<3){return}var s=this.idDomainDnsInfo.rows[1];var t=this.idDomainDnsInfo.rows[2];var a=i.split(".");var n=/^(com|net|org|co|kiev|spb|kharkov|msk|in|app)\.[a-z]{2}$/;t.style.display="none";s.cells[0].textContent=i?i:"landing.mydomain";if(a.length===2||a.length===3&&a[0]==="www"||a.length===3&&(a[1]+"."+a[2]).match(n)){t.style.display="table-row";if(a.length===3&&a[0]==="www"){t.cells[0].textContent=a[1]+"."+a[2]+"."}else{s.cells[0].textContent="www."+i+".";t.cells[0].textContent=i+"."}}}}]);return e}();var a=function(e){babelHelpers.inherits(i,e);function i(e){babelHelpers.classCallCheck(this,i);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(i).call(this,e))}return i}(t);var n=function(e){babelHelpers.inherits(i,e);function i(e){babelHelpers.classCallCheck(this,i);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(i).call(this,e))}return i}(t);var o=function(){function e(t){babelHelpers.classCallCheck(this,e);this.idDomainSubmit=t.idDomainSubmit;this.idDomainCheck=t.idDomainCheck;this.idDomainName=t.idDomainName;this.idDomainAnother=t.idDomainAnother;this.idDomainAnotherMore=t.idDomainAnotherMore;this.idDomainErrorAlert=t.idDomainErrorAlert;this.saveBlocker=t.saveBlocker;this.saveBlockerCallback=t.saveBlockerCallback;this.promoCloseIcon=t.promoCloseIcon;this.promoCloseLink=t.promoCloseLink;this.promoBlock=t.promoBlock;this.maxVisibleSuggested=parseInt(t.maxVisibleSuggested||10);this.tld=t.tld?t.tld.toLowerCase():"tld";this.helper=new s(t);this.classes={submit:"ui-btn-clock"};if(this.promoCloseIcon&&this.promoCloseLink){i.Event.bind(this.promoCloseIcon,"click",this.closePromoBlock.bind(this));i.Event.bind(this.promoCloseLink,"click",this.closePromoBlock.bind(this))}if(this.idDomainAnotherMore){i.Event.bind(this.idDomainAnotherMore,"click",this.showMoreDomains.bind(this))}if(this.idDomainSubmit){i.Event.bind(this.idDomainSubmit,"click",function(e){this.checkSubmit(e)}.bind(this))}if(this.idDomainCheck&&this.idDomainName){i.Event.bind(this.idDomainCheck,"click",function(e){this.checkDomain(e)}.bind(this))}if(this.idDomainName){i.Event.bind(this.idDomainName,"keyup",i.Runtime.debounce(function(e){this.keyupCallback(e)}.bind(this),500,this))}}babelHelpers.createClass(e,[{key:"keyupCallback",value:function e(){if(this.idDomainName.value===""){this.helper.setError(i.Loc.getMessage("LANDING_TPL_ERROR_DOMAIN_EMPTY"));return}this.helper.setSuccess("")}},{key:"closePromoBlock",value:function e(){this.promoBlock.remove()}},{key:"showMoreDomains",value:function e(){this.idDomainAnother.style.height=this.idDomainAnother.children[0].offsetHeight+"px";this.idDomainAnotherMore.classList.add("landing-domain-block-available-btn-hide")}},{key:"checkSubmit",value:function e(s){if(i.Dom.hasClass(this.idDomainSubmit,this.classes.submit)){s.preventDefault();return}this.checkDomainName();if(this.helper.isErrorShowed()){s.preventDefault()}else if(this.saveBlocker&&this.saveBlockerCallback){this.saveBlockerCallback();s.preventDefault()}else{i.Dom.addClass(this.idDomainSubmit,this.classes.submit)}}},{key:"selectSuggested",value:function e(s){this.idDomainName.value=s;this.helper.setSuccess(i.Loc.getMessage("LANDING_TPL_DOMAIN_AVAILABLE"))}},{key:"fillSuggest",value:function e(s){var t=this;if(!this.idDomainAnother){return}if(this.idDomainAnotherMore){if(s.length>this.maxVisibleSuggested){i.Dom.show(this.idDomainAnotherMore);this.idDomainAnotherMore.classList.remove("landing-domain-block-available-btn-hide")}else{i.Dom.hide(this.idDomainAnotherMore)}}if(s.length){i.Dom.show(this.idDomainAnother.parentNode)}else{i.Dom.hide(this.idDomainAnother.parentNode)}var a=[];for(var n=0,o=s.length;n<o;n++){a.push(i.Dom.create("div",{props:{className:"landing-domain-block-available-item"},children:[i.Dom.create("input",{props:{className:""},attrs:{name:"domain-edit-suggest",id:"domain-edit-suggest-"+n,type:"radio"},events:{click:function e(i){t.selectSuggested(s[i])}}}),i.Dom.create("label",{props:{className:"landing-domain-block-available-label"},attrs:{for:"domain-edit-suggest-"+n},text:s[n]})]}))}this.idDomainAnother.innerHTML="";this.idDomainAnother.appendChild(i.Dom.create("div",{props:{className:"landing-domain-block-available-list"},children:a}));if(this.idDomainAnotherMore.style.display==="none"){this.idDomainAnother.style.height=this.idDomainAnother.children[0].offsetHeight+"px"}else{this.idDomainAnother.style.height=80+"px"}}},{key:"checkDomainName",value:function e(){this.idDomainName.value=i.Type.isString(this.idDomainName.value)?this.idDomainName.value.trim():this.idDomainName.value;var s=RegExp("^[a-z0-9-]+."+this.tld+"$");if(this.idDomainName.value===""){this.helper.setError(i.Loc.getMessage("LANDING_TPL_ERROR_DOMAIN_EMPTY"))}else if(!s.test(this.idDomainName.value.toLowerCase())){this.helper.setError(i.Loc.getMessage("LANDING_TPL_ERROR_DOMAIN_CHECK"))}else if(this.idDomainName.value.indexOf("--")!==-1||this.idDomainName.value.indexOf("-.")!==-1||this.idDomainName.value.indexOf("-")===0){this.helper.setError(i.Loc.getMessage("LANDING_TPL_ERROR_DOMAIN_CHECK_DASH"))}}},{key:"checkDomain",value:function e(s){s.preventDefault();if(this.helper.isLoaderShowed()){return}this.checkDomainName();if(this.helper.isErrorShowed()){return}this.helper.showLoader();this.fillSuggest([]);BX.ajax({url:"/bitrix/tools/landing/ajax.php?action=Domain::whois",method:"POST",data:{data:{domainName:this.idDomainName.value,tld:this.tld},sessid:i.Loc.getMessage("bitrix_sessid")},dataType:"json",onsuccess:function(e){this.helper.hideLoader();if(e.type==="success"){var s=e.result;if(!s.enable){if(s.suggest){this.fillSuggest(s.suggest)}this.helper.setError(i.Loc.getMessage("LANDING_TPL_ERROR_DOMAIN_EXIST"))}else{this.helper.setSuccess(i.Loc.getMessage("LANDING_TPL_DOMAIN_AVAILABLE"))}}}.bind(this)})}}]);return e}();e.Helper=s;e.Input=t;e.Private=a;e.Bitrix24=n;e.Free=o})(this.BX.Landing.SiteDomain=this.BX.Landing.SiteDomain||{},BX);
//# sourceMappingURL=script.map.js